import React,{useEffect , useState} from 'react'
import {NavBar,Toast} from "react-vant"
import {useParams,useLocation,useMatch} from "react-router-dom"
function Myheader() {
   let [title, setTitle] = useState("历史记录")
   let [flag,setFlag] = useState(true)
//   let params = useParams()
  let location = useLocation()
  let Match = useMatch(location.pathname)
  console.log(Match);
//   console.log(params);
  console.log(location);
  useEffect(()=>{
    // console.log(location.pathname);
    if (location.pathname === "/history") {
        setTitle("历史记录")
    } else if (location.pathname === "/weight") {
        setTitle("体重")
    } else if (location.pathname === "/line") {
        setTitle("近七天体重")
    }
    if (location.pathname === "/login" ) {
        setFlag(false)
    } else {
        setFlag(true)
    }
  },[location.pathname])
  return (
    <div>
        {
            flag ? <NavBar
            title={title}
            leftText="返回"
            rightText="按钮"
            onClickLeft={() => Toast('返回')}
            onClickRight={() => Toast('按钮')}
        /> : null
        }
         
    </div>
  )
}

export default Myheader